home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c-part1 / 8571 < prev    next >
Encoding:
Internet Message Format  |  1996-08-05  |  2.0 KB

  1. Path: s02.pavilion.co.uk!usenet
  2. From: AJRobb@pavilion.co.uk (Andy J Robb)
  3. Newsgroups: comp.lang.c
  4. Subject: Re: need for function prototypes
  5. Date: Tue, 05 Mar 1996 03:18:02 GMT
  6. Organization: Pavilion Internet plc
  7. Message-ID: <4hgbo0$2fj@s02.pavilion.co.uk>
  8. References: <4gutho$o1a@mn5.swip.net>
  9. NNTP-Posting-Host: poolc35.pavilion.co.uk
  10. X-Newsreader: Forte Free Agent 1.0.82
  11.  
  12. chris.rossall@mailbox.swipnet.se (Chris Rossall) wrote:
  13.  
  14. >Hello I am having trouble understanding why I should use function
  15. >prototypes. I mean,if the function is defined before it is used,the
  16. >compiler should have enough information about the parameters to
  17. >produce correct code anyway.
  18.  
  19. >-Chris 
  20.  
  21. -----BEGIN PGP SIGNED MESSAGE-----
  22.  
  23. True, a function definition before a function call will serve as its
  24. own declaration especially if it is restricted to file scope (static).
  25. A lot of programs are written top-down.  This leaves the function
  26. definition after the function call.  To get around this, insert a
  27. function declaration before the function call.
  28.  
  29. Function prototypes come in to their own when defining functions with
  30. external linkage.  The declaration of these functions can then be
  31. included in other files where the function is called.  Also, including
  32. the header file in the function source file allows the declaration to
  33. be checked against the definition.
  34.  
  35. Regards,
  36. Andy Robb.
  37.  
  38. -----BEGIN PGP SIGNATURE-----
  39. Version: 2.6.2i
  40.  
  41. iQCVAwUBMTuyNpPl4P16x9sNAQFVIQQAvrKwK4vAjiGNYlP9olcWw6HkcJotYOhR
  42. PDtvkY5d6ZWKCiv/7zrpI3Z/rAh5ThbSqzSQxdu7pM+rwQJf98D+lTXv+pD4m1Yr
  43. zgr2+b88j5ttawySeQuzfOOCItb/jK5nSFMHQ1UO2o2Y8o3ELrCgG06tMAcmPaKW
  44. DCwdsVWMpIw=
  45. =dAKB
  46. -----END PGP SIGNATURE-----
  47.  
  48. -----BEGIN PGP PUBLIC KEY BLOCK-----
  49. Version: 2.6.2i
  50.  
  51. mQCNAy/MpRwAAAEEAOt6uBYqT8yv9EmqNhK8m6v+bYi8QjnGW3Bo6iU1gsMj5pa6
  52. MHgq99c8deADbE3cbJ6uZS9v5pZE3WCf6HCQjlB5iULA5RZzMdAumd/WUzuL9UT3
  53. B44D9EqqFIL79FlYb56v4oKFqFp1/J2bIpYUwnUvabGzGjdLrpPl4P16x9sNAAUR
  54. tCNBbmR5IEogUm9iYiA8QUpSb2JiQHBhdmlsaW9uLmNvLnVrPrQhQW5keSBSb2Ji
  55. IDxBSlJvYmJAcGF2aWxpb24uY28udWs+
  56. =/wVD
  57. -----END PGP PUBLIC KEY BLOCK-----
  58.  
  59.